function genAutoCode(args){
	if(args.lock == true){
		$(args.labelTarget).show();
		$(args.labelSource).hide();	
		return;	
	}
	
	var strInput = Utils.transliterate($(args.source).val());
	$(args.target).html(strInput).val(strInput);
	if(strInput != ''){
		$(args.labelSource).show();	
	}else{
		$(args.labelTarget).hide();	
	}
	//add event
	$(args.source).bind('change keyup', function(){
		var strInput = Utils.transliterate($(args.source).val());
		$(args.target).html(strInput).val(strInput);
		if(strInput != ''){
			$(args.labelSource).show();	
		}else{
			$(args.labelTarget).hide();	
		}
	});
	//
	$(args.button).click(function(){
		$(this).hide();
		$(args.source).unbind('change keyup');	
		$(args.labelSource).hide();
		$(args.labelTarget).show();
	});
}

/* check if browser is IE
   Example: if (isIE()) || if(isIE() < 8)
*/
function isIE() {
  var myNav = navigator.userAgent.toLowerCase();
  return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}

function redirect(url)
{
	window.location = url;
}

function isset(obj) {
    if ((typeof (obj) === 'undefined') || (obj === null))
        return false;
    else
        return true;
};

//AnhDKD: set cookie
function setCookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

//AnhDKD: get cookie
function getCookie(c_name)
{
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	{
		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x=x.replace(/^\s+|\s+$/g,"");
		if (x==c_name)
		{
			return unescape(y);
		}
	}
}

function deleteCookie(c_name) {
    document.cookie = c_name + "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
};

/************************* FUNCTIONS **************************/

function show_confirm(msg, msg_ok, msg_cancel)
{
	var r=confirm(msg);
	if (r==true){
		if(msg_ok)
			alert(msg_ok);
	}
	else{
		if(msg_cancel)
			alert(msg_cancel);
	}
	return r;
}

/*Select all checkboxes*/
function selectAll(obj)
{
	$("input:not(:disabled)[type='checkbox']").prop("checked" , obj.checked);
}

/*Get value of selected checkboxes*/
function getSelectedByName(objname){
	var ids = '';
	$("INPUT[name^='"+objname+"'][disabled!='true']").each(function () {
		if($(this).is(':checked'))
			ids += $(this).val() + ',';
	});
	return ids.replace(/[\s,]+$/, '');;
}